#ifndef AST_STATEMENT_STATEMENT_H
#define AST_STATEMENT_STATEMENT_H

#include "../ASTNode.h"

class LabeledStmt;
class CompoundStmt;
class ExpressionStmt;
class SelectionStmt;
class IterationStmt;
class JumpStmt;

/*
C99   6.8
statement:
		labeled-statement
		compound-statement
		expression-statement
		selection-statement
		iteration-statement
		jump-statement
*/
class Statement : public ASTNode
{
public:
	enum{
		labled_stmt,
		compound_stmt,
		expression_stmt,
		selection_stmt,
		iteration_stmt,
		jump_stmt,
	};
protected:
	Statement(void)
		: ASTNode(ASTNode::statement){};
public:
	Statement(LabeledStmt *pStmt)
		: ASTNode(ASTNode::statement)
		, m_iType(labled_stmt)
		, m_pLabeledStmt(pStmt){};

	Statement(CompoundStmt *pStmt)
		: ASTNode(ASTNode::statement)
		, m_iType(compound_stmt)
		, m_pCompoundStmt(pStmt){};

	Statement(ExpressionStmt *pStmt)
		: ASTNode(ASTNode::statement)
		, m_iType(expression_stmt)
		, m_pExprStmt(pStmt){};

	Statement(SelectionStmt *pStmt)
		: ASTNode(ASTNode::statement)
		, m_iType(selection_stmt)
		, m_pSelectionStmt(pStmt){};

	Statement(IterationStmt *pStmt)
		: ASTNode(ASTNode::statement)
		, m_iType(iteration_stmt)
		, m_pIterationStmt(pStmt){};

	Statement(JumpStmt *pStmt)
		: ASTNode(ASTNode::statement)
		, m_iType(jump_stmt)
		, m_pJumpStmt(pStmt){};

	virtual ~Statement(void);

	virtual void					codeGen();
protected:
	tiny_int						m_iType;
	union{
		LabeledStmt *				m_pLabeledStmt;
		CompoundStmt *				m_pCompoundStmt;
		ExpressionStmt *			m_pExprStmt;
		SelectionStmt *				m_pSelectionStmt;
		IterationStmt *				m_pIterationStmt;
		JumpStmt *					m_pJumpStmt;
	};
};


#endif


